package com.dcivision.customize;

import java.util.Locale;

import com.dcivision.framework.MessageResourcesFactory;

public class CustomizedOptionsTag extends org.apache.struts.taglib.html.OptionsTag {

  public static final String REVISION = "$Revision: 1.6 $";

  protected String[][] saStringArray = null;
  protected String sDbListName = null;
  protected String sListName = null;
  protected String sListArg1 = null;
  protected String sListArg2 = null;
  protected Integer sListArg3 = null;
  protected boolean bHasSelect = true;
  protected String sDisplayLabel = null;
  protected boolean bConvertLabel = true;
  protected boolean bNowrap = false;

  public CustomizedOptionsTag() {
    super();
  }

  public String[][] getStringArray() {
    return saStringArray;
  }

  public void setStringArray(String[][] strAry) {
    this.saStringArray = strAry;
  }

  public String getDbListName() {
    return sDbListName;
  }

  public void setDbListName(String sDbListName) {
    this.sDbListName = sDbListName;
  }

  public String getListName() {
    return sListName;
  }

  public void setListName(String sListName) {
    this.sListName = sListName;
  }

  public String getListArg1() {
    return sListArg1;
  }

  public void setListArg1(String sListArg1) {
    this.sListArg1 = sListArg1;
  }

  public String getListArg2() {
    return sListArg2;
  }

  public void setListArg2(String sListArg2) {
    this.sListArg2 = sListArg2;
  }
  
  public Integer getListArg3() {
	    return sListArg3;
	  }

  public void setListArg3(Integer sListArg3) {
	    this.sListArg3 = sListArg3;
	  }
  
  public boolean getHasSelect() {
    return bHasSelect;
  }

  public void setHasSelect(boolean bHasSelect) {
    this.bHasSelect = bHasSelect;
  }

  public String getDisplayLabel() {
    return sDisplayLabel;
  }

  public void setDisplayLabel(String sDisplayLabel) {
    this.sDisplayLabel = sDisplayLabel;
  }

  public boolean getConvertLabel() {
    return bConvertLabel;
  }

  public void setConvertLabel(boolean bConvertLabel) {
    this.bConvertLabel = bConvertLabel;
  }

  public boolean getNowrap() {
    return bNowrap;
  }

  public void setNowrap(boolean bNowrap) {
    this.bNowrap = bNowrap;
  }

  protected String[] getLabels(String[] asMsgKeys) {
    String[] asResult = new String[asMsgKeys.length];
    Locale currLoc = (Locale)pageContext.getSession().getAttribute(org.apache.struts.Globals.LOCALE_KEY);
    for (int i=0; i<asMsgKeys.length; i++) {
      asResult[i] = MessageResourcesFactory.getMessage(currLoc, asMsgKeys[i]);
    }
    return(asResult);
  }

  protected String getSqlStatement(String sDbListName) throws Exception {
    /*************************************************************************
    String sqlStat = null;

    // select query to table according to sListName
    if ( OptionsListConstant.DBLIST_COUNTRY.equals(sDbListName) ) {
      sqlStat.append("SELECT    ID, COUNTRY_NAME, DISPLAY_SEQ ");
      sqlStat.append("FROM      SETUP_OPTION_COUNTRY ");
      sqlStat.append("WHERE     RECORD_STATUS = 'A' AND STATUS = 'A' ");
      sqlStat.append("ORDER BY  DISPLAY_SEQ ASC, COUNTRY_NAME ASC ");

    }

    return sqlStat;
    **************************************************************************/
    throw new Exception("No List Found");
  }

  protected Object[] getListData(String sListName) throws Exception {
    /*************************************************************************
    String[] asName;
    String[] asLabelName;
    if ( OptionsListConstant.LIST_STATUS_TYPE.equals(sListName) ) {
      asName = new String[] {GlobalConstant.STATUS_ACTIVE, GlobalConstant.STATUS_INACTIVE};
      asLabelName = new String[] { "common.options.status_A",
                                   "common.options.status_I"
                                 };
    }

    return new Object[] { asName, this.getLabels(asLabelName) };
    **************************************************************************/
    throw new Exception("No List Found");
  }

}
